<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/22
 * Time: 14:59
 */
require_once  Root.'/vendor/autoload.php';
class CtlIndex extends BaseController
{
    public function index()
    {
        $this->tpl = 'index.tpl';
    }

    public function refresh(){
        $cache = $this->R("type");
        $key = $this->R("key");
        $mem = CommonCache::getInstance($cache);
        $mem->deleteCache($key);
        header("Location: " . APP_URL); //跳转到首页
        exit;
    }

    public function getUserList(){
        $room_id = $this->R("room_id");
        if(empty($room_id)){
            $msg["ret"] = false;
            $msg["data"] = array();
        }else {
            //获取当前在线用户
            $userList = array();
            $redis = CommonCache::getInstance("authRedis");
            $userList = $redis->getCache($room_id . "_user_list");
            $msg["ret"] = true;
            $msg["data"] = $userList;
        }
        echo json_encode($msg);
        exit;
    }
}